const { Sequelize } = require("sequelize");
// 方法 3: 分别传递参数 (其它数据库)
module.exports = async function (fastify, options) {
  const sequelizeInstance = await new Sequelize("test", "root", "123456", {
    host: "localhost",
    dialect: "mysql",
    port: "3308",
    logging: console.log,
  });
  fastify.decorate("sequelize", sequelizeInstance);
  fastify.addHook("onClose", (instance, done) =>
    sequelizeInstance.close().then(() => done())
  );
  await sequelizeInstance.authenticate();
};
